package com.param;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

import com.entity.Info;

public class Init {
	public static File imgPath;
	public static Map<String,Info> imgMap=new HashMap<>();
	static{
		//初始化图片的路径
		//读取配置文件
		Properties properties=new Properties();
		InputStream resourceAsStream = Init.class.getClassLoader().getResourceAsStream("imgPath.properties");
		try {
			properties.load(resourceAsStream);
			String pathStr = properties.getProperty("path");
			imgPath=new File(pathStr);
		} catch (IOException e) {
			e.printStackTrace();
		}
		finally {
			try {
				if(resourceAsStream!=null){
					resourceAsStream.close();
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}
	
	private static String pwd="yueheng";
	
	/**
	 * 图片加密
	 * @param os
	 */
	public synchronized static void encryption(OutputStream os){
		
		try {
			os.write(pwd.getBytes());
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	/**
	 * 图片解密
	 * @param os
	 */
	public synchronized static long decrypt(){
		return pwd.getBytes().length;
	}
	
}
